package study.thread;

public class ThreadTest {
    static class MyRunnable implements Runnable{
        static int j=10;
        @Override
        public synchronized void run() {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName()+",  i="+j--);
                if(i%2 == 0)
                    Thread.yield();
            }
        }
    }
    public static void main(String[] args){
        MyRunnable myRunnable = new MyRunnable();
        Thread t1 = new Thread(myRunnable);
        Thread t2 = new Thread(myRunnable);
        t1.start();
        t2.start();
    }
}
